<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title> 3-8 编程练习</title>
    <link rel="stylesheet" type="text/css" href="../../../css/style.css"/>
    <style type="text/css">
    </style>

    <script type="text/javascript">
        //创建数组
        var Arr=['*','**','***','****']
        //显示数组长度
        document.write(Arr.length+"<br>");

        //将数组内容输出，完成达到的效果。
        document.write(Arr[0]+"<br>"+Arr[1]+"<br>"+Arr[2]+"<br>"+Arr[3]+"<hr>");




        //网友写的
        //创建数组
        var  arr = ['*','##',"***","&&","****","##*"];
        arr[7] = "**";
        //数组长度
        var l = arr.length;

        //删除数组中非*的项
        var i = 0;
        for(; i < l; i++){
            var val = arr[i];

            if(val != undefined) {
                var newarr = val.split('');
                var newl = newarr.length;
                for(var j = 0; j < newl; j++){
                    if(newarr[j] != '*'){
                        arr.splice(i, 1);
                        break;
                    }
                }
            }
        }

        //按照字符数排序
        arr.sort(function(a, b){
            if(a.length > b.length){
                return 1
            }else if(a.length < b.length){
                return -1
            }else{
                return 0
            }
        })


        //将数组内容输出，完成达到的效果。
        for(var i = 0; i < l; i++){
            if(arr[i] != undefined){
                document.write(arr[i] + '<br />')
            }
        }


    </script>
</head>

<body>
<div align="center">
    <p><a href="../../index.php#jsjjp" class="fontSize" title="点击进入该目录">目录</a></p>
</div>

<!--<input type="button" onclick="zhencha()" value="点击查询"/>-->

<script type="text/javascript">

</script>

</body>
</html>
